<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<!--[if lt IE 9]>
<script type="text/javascript" src="lib/html5.js"></script>
<script type="text/javascript" src="lib/respond.min.js"></script>
<script type="text/javascript" src="lib/PIE_IE678.js"></script>
<![endif]-->
<link href="css/H-ui.min.css" rel="stylesheet" type="text/css" />
<link href="css/H-ui.admin.css" rel="stylesheet" type="text/css" />
<link href="css/style.css" rel="stylesheet" type="text/css" />
<link href="lib/Hui-iconfont/1.0.7/iconfont.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="lib/daterangepicker/daterangepicker.css" /> 
<!--[if IE 6]>
<script type="text/javascript" src="lib/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
<title>订单详情</title>
<style type="text/css">


</style>
</head>
<body>
<div class="pd-20" id="detail">
	<script id="test" type="text/html">
	<table class="table table-border table-bordered table-bg table-sort">
		<thead>
			<tr class="text-c">
				<th class="text-l">
					<span class="pr-20">订单编号:<%if(list.order_number==0){%><%=list.pay_order_number%><%}else{%><%=list.order_number%><%}%> (ID:<%=list.order_id%>)</span>
					<span class="pr-20">订单时间:<%=list.order_time%></span>
					
					<span class="pr-20">订单金额:运费：<%=list.total_transport%>／金额：<%=list.total_fee%></span>


					<span class="pr-20" style="float: right">
						<span class="pr-20" title="<%=list.cancel_reason%>">
							订单状态:
							<%if(list.order_state==51){%>
							<label style="color:#f37b1d; cursor: pointer;" onclick="_open('退款详情','order-refund-detail.html?oid=<%=list.order_id%>&reason=<%=list.cancel_reason%>','80%','70%',false)"><%=list.order_state_cn%></label>
							<%}else{%>
							<label style="color:#f37b1d;"><%=list.order_state_cn%></label>
							<%}%>
						</span>


						<%if(list.order_state==10 || list.order_state==52){ %>
		
								<span class="label label-success radius" data-flag="5" style="cursor: pointer;" onClick="_open('发货','order-trans-add.html?order_state=<%=list.order_state%>&oid=<%=list.order_id%>','80%','70%',false)">发货</span>
			
						<%}else if(list.order_state==50){%>
								
								<!-- <span class="label radius fun-refund" data-flag="1" style="cursor: pointer;">同意</span>
								<span class="label radius fun-refund" data-flag="2" style="cursor: pointer;" title="<%=list.cancel_reason%>">不同意</span> -->
		
							
						<%}%>
						
					</span>
				</th>
			</tr>

		</thead>
		<tbody id="content_sp">
			<tr class="text-l va-m" >
				<td>
					<div>
						
						<p><b>联系人：</b><%=list.receiver%> (<%=list.uid%>)</p>
						<p><b>联系电话：</b><%=list.mobile%></p>
						<p><b>收货地址：</b><%=list.province_name%><%=list.city_name%><%=list.address%></p>
						
						<p><b>备注信息：</b><%=list.admin_remark%></p>

						
									
					</div>
					<div>
						<table class="table table-border table-bordered table-bg table-sort">
							<thead>
								<tr class="text-c sort0">
									<th width="40" class="valueid"><input name="" type="checkbox" value=""></th>
									<th width="60">商品ID</th>

									<th>商品名称</th>
									<th width="80">缩略图</th>

									<th width="60">价格</th>
									<th width="60">数量</th>
									<th width="60">状态</th>
									<!-- <th width="100">操作</th> -->
								</tr>
							</thead>
							<tbody id="goodslist">
								<% for (j in list.goods) { %>
								<tr class="text-c sort1">
									<td class="valueid"><input data-sid="<%=list.goods[j].sku_id%>" name="" type="checkbox" value="<%=list.goods[j].goods_id%>" <%if(list.goods[j].order_list_state!=='101'){%> disabled <%}%>></td>
									<td class=""><%=list.goods[j].goods_id%></td>
									<td class="text-l ">
										<%=list.goods[j].goods_name%><%if(list.goods[j].sku_info!==""){%>( 规格：<%=list.goods[j].sku_info%>[<%=list.goods[j].sku_id%>] )<%}%>
									</td>
									<td><img class="pic-thumb" src="<%=list.goods[j].goods_image%>"></td>
									<td class="text-l ">
										<%=list.goods[j].goods_price%> 
										
									</td>
									<td class="text-l "><%=list.goods[j].num%></td>
									<td class="g-status">
										
										<%if(list.goods[j].order_list_state=='0' && list.goods[j].order_list_state_cn==""){%>
											<%=list.order_state_cn%>
										<%}else{%>
											<%=list.goods[j].order_list_state_cn%>
										<%}%>
									</td>
									<!-- <td class="td-manage f-18">
										
 											<span class="label radius label-success fun-admin-refund" data-id="<%=list.goods[j].goods_id%>" style="cursor: pointer;">退款</span>
 										
									</td> -->
								</tr>
								<%}%>
							</tbody>
						</table>
						<div class="cl pd-5 bg-1 bk-gray mt-10"> 
							
<!-- 							<a href="javascript:;" class="btn btn-warning l mr-10 mt-5 radius fun-admin-allrefund" data-flag=1><i class="Hui-iconfont">&#xe6de;</i> 退 [ 钱 + 券 ]</a>  -->

							<a href="javascript:;" class="btn btn-danger l mr-10 mt-5 radius fun-admin-allrefund" data-flag=0><i class="Hui-iconfont">&#xe6a6;</i> 拒绝</a> 

							<!-- <a href="javascript:;" class="btn btn-success l mr-10 mt-5 radius fun-refund-quan" data-flag=1><i class="Hui-iconfont">&#xe6ca;</i> 只退券</a>  -->
							
							<a href="javascript:;" class="btn btn-secondary l mr-10 mt-5 radius fun-refund-money" data-flag=0><i class="Hui-iconfont">&#xe63a;</i> 退钱</a> 
							
							
						</div>
					</div>
					<div id="tt">
						<p><b>其他信息</b></p>
						<p><b>formid</b><%=list.formid%> </p>
						<p style="max-width: 800px;"><b>payment</b><%=list.payment%></p>
						<p><b>prepay_id：</b><%=list.prepay_id%></p>
						<p><b>quan_detail：</b><%=list.quan_detail%></p>
						<p style="border-top:#333 1px dashed;border-bottom:#333 1px dashed"><b>发货信息</b></p>
						<p><b>发货时间：</b><%=list.admin_addtime%></p>
						<!-- <div style="padding: 10px; background-color: #ddd;margin-bottom: 10px;">
							<p><b>快递公司：</b><%=list.admin_shipping_name%></p>
							<p onClick="_open('物流详情','order-trans-detail.html?oid=<%=list.order_id%>&index=<%=k%>','50%','70%',true)" style="cursor: pointer;"><b>快递单号：</b><%=list.admin_shipping_num%></p>


							
						</div> -->
						<% for (k in list.shipping) { %>
						<div style="padding: 10px; background-color: #ddd;margin-bottom: 10px;">
							<p><b>快递公司：</b><%=list.shipping[k].shipping_name%></p>
							<p onClick="_open('物流详情','order-trans-detail.html?oid=<%=list.order_id%>&index=<%=k%>','50%','70%',true)" style="cursor: pointer;"><b>快递单号：</b><%=list.shipping[k].shipping_num%></p>
						</div>
						<%}%>
							
						<p style="border-top:#333 1px dashed;border-bottom:#333 1px dashed"><b>支付信息</b></p>
						<p><b>支付时间：</b><%=list.pay_time%></p>
						<p><b>支付方式：</b><%=list.pay_type_cn%></p>	
						<p class="label label-danger radius" style="cursor: pointer;" onclick="_open('支付详情','order-pay-detail.html?oid=<%=list.order_id%>&reason=<%=list.cancel_reason%>','80%','70%',false)">
							查看支付详情
						</p>
						
						<p style="border-top:#333 1px dashed;border-bottom:#333 1px dashed"><b>退款信息</b></p>
						<p><b>退款金额：</b><%=list.refund_fee%></p>
						<p><b>退券：</b><%=list.refund_quan%></p>
						<p><b>退款原因：</b><%=list.cancel_reason%></p>
						
						<p class="label label-danger radius" style="cursor: pointer;" onclick="_open('退款详情','order-refund-detail.html?oid=<%=list.order_id%>&reason=<%=list.cancel_reason%>','80%','70%',false)">
							查看退款详情
						</p>
						
					</div>
					
				</td>
			</tr>
		</tbody>
	</table>
	<div class="cl pd-5 bg-1 bk-gray mt-10 text-r"> 
		<div style="float: right;">
<!-- 			<a class="btn btn-primary radius mt-5 l mr-10" data-title="添加内容" href="javascript:;" onclick="_open('打印订单','order-paper-print.html?oid=<%=list.order_id%>','90%','90%',false)" href="javascript:;">
				<i class="Hui-iconfont">&#xe652;</i> 打印
			</a> -->
			

			
		</div>
	</div>
	</script>
</div>





<script type="text/javascript" src="lib/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="js/H-ui.js"></script>
<script type="text/javascript" src="lib/layer/2.1/layer.js"></script> 
<script type="text/javascript" src="js/H-ui.admin.js"></script> 
<script type="text/javascript" src="js/template-native.js"></script> 
<script type="text/javascript" src="js/s.js"></script> 
<script type="text/javascript" src="lib/laypage/laypage.js"></script> 
<script type="text/javascript" src="lib/daterangepicker/moment.min.js"></script> 
<script type="text/javascript" src="lib/daterangepicker/jquery.daterangepicker.js"></script>
<script src="/Manage/js/lazyload.min.js"></script>
<script type="text/javascript">
var API=API_ORDERLIST;
var kk;

var oid=getUrlParam('oid');//编辑菜单id
$.getJSON(API+'?oid='+oid,function(data){
	layer.load();
	if(!checkStatus(data)) return;//判断登录

	if(data.datas==''){
		layer.msg("数据加载错误", {icon:2,time:1000});
	}else{
		var data={'list':data.datas};
        var html=template('test',data);
        $("#detail").html(html);
        layer.closeAll('loading');
        //全选按钮

        $(".sort0 .valueid input:checkbox").on("click" , function(){
            $(this).closest("table").find(".valueid input:checkbox:not(:disabled)").prop("checked",$(this).prop("checked"));
        });
        // 取消全选
        $(document).on('click','.sort1 .valueid input:checkbox',function(){
            // 展开子分类
            $(this).parent().parent().nextUntil('.sort1').find('.valueid input:checkbox:not(:disabled)').prop("checked",$(this).prop("checked"));
            var checklen1=$(".sort1 .valueid input:checkbox:checked:not(:disabled)").length;
            var len1=$(".sort1 .valueid input:checkbox:not(:disabled)").length;
            $(".sort0 input:checkbox:not(:disabled)").prop("checked",checklen1==len1);//全选按钮
        })
        // 单个取消订单
        $(document).on('click','span.fun-refund',function(){
        	var flag=$(this).data("flag");
        	
        	
        	var that=$(this);
        	if(flag==1){
        		layer.confirm('退款后,券和运费将打到用户账户?',function(index){
        			layer.close(index);
        	        layer.load();
        	        $.post(API_ORDERLIST,{
        	        	oid:oid,
        	        	type:'refund',
        	        },function(data){
        	        	// data=eval("( "+data+" )");
        	        	if(!checkStatus(data)) return;
        	        	layer.closeAll('loading');
        	        	that.parent().html("已同意√")

        			    
        	        },'json')
        	    })
        	}else if(flag==2){
        		layer.use('extend/layer.ext.js', function(){
        			layer.prompt({
        		        title:'拒绝理由',
        		    },function(val, index){
        		        layer.close(index);
        		        layer.load();
        		        $.post(API_ORDERLIST,{
        		        	oid:oid,
        	        		type:'norefund',
        		        },function(data){
        		        	if(!checkStatus(data)) return;
        		        	layer.closeAll('loading');
        		        	that.parent().html("已拒绝×")
        		        },'json')
        		    })
        		})
        	}
        	
        })
        // 只退券
        $(document).on('click','a.fun-refund-quan',function(){
        	var quan=data.list.total_quan;
        	var oid=data.list.order_id;
        	layer.use('extend/layer.ext.js', function(){
				layer.prompt({
			        title:'所退券数',
			    },function(val, index){
			    	console.log(quan)
			    	if(parseInt(val)>parseInt(quan)){
			    		layer.msg('退券数不能高于支付券数', {icon:5,time:2000});
			    	}else{
			    		layer.close(index);
			    			

    			        $.post(API_REFUND_QUAN,{
    			        	oid:oid,
    		        		quan:val,
    			        },function(data){
    			        	if(!checkStatus(data)) return;
    			        	layer.msg(data.info, {icon:1,time:2000});
    			        },'json')
			    	}
			        
			    })
			})
        })
        // 只退钱
        $(document).on('click','a.fun-refund-money',function(){
        	var fee=data.list.total_fee;
        	var oid=data.list.order_id;
        	layer.use('extend/layer.ext.js', function(){
				layer.prompt({
			        title:'所退钱数',
			    },function(val, index){
			    	console.log(fee)
			    	if(parseInt(val)>parseInt(fee)){
			    		layer.msg('退钱数不能高于支付金额', {icon:5,time:2000});
			    	}else{
			    		layer.close(index);
			    			

    			        $.getJSON(API_REFUND_MONEY,{
    			        	oid:oid,
    		        		fee:val,
    		        		type:'refund712',
    			        },function(data){
    			        	if(!checkStatus(data)) return;
    			        	layer.msg(data.info, {icon:1,time:2000});
    			        })
			    	}
			        
			    })
			})
        })
        // 后台商品批量退款
        $(document).on('click','a.fun-admin-allrefund',function(){
        	var flag=$(this).data("flag");
        	var ids="";
        	var sid="";
			$("#goodslist .valueid input[type='checkbox']:checked").each(function(e){
	            ids=ids+$(this).val()+",";
	            sid=sid+$(this).data("sid")+",";
	        })
	        if(ids==""){
	        	layer.msg("至少选择一件商品",{icon:2,time:1000});
	        	return; 
	        }
	        
        	if(flag==1){
	        	layer.confirm('退款后,券和运费将打到用户账户?',function(index){
					layer.close(index);					
					layer.load();			        	
			        $.post(API_ORDERGOODS_REFUND,{
			        	oid:oid,
			        	type:'refund',
			        	gid:ids,
			        	sku_id:sid,
			        },function(data){
			        	if(!checkStatus(data)) return;		        	
			        	layer.closeAll('loading');
				        $("#goodslist .valueid input[type='checkbox']:checked").each(function(){
		        	   		$(this).closest("tr.sort1").find("td.g-status").html("已退款");
		        	   	})
		        	   	$("tr.sort0 input[type='checkbox']:checked").prop("checked",false);
		        		$("#goodslist .valueid input[type='checkbox']:checked").prop("checked",false);
			        	layer.msg(data.info,{icon:1,time:1000}); 
			        },'json')
			    })
        	}else if(flag==0){
		        $.post(API_ORDERGOODS_REFUND,{
		        	oid:oid,
		        	type:'norefund',
		        	gid:ids,
		        	sku_id:sid,
		        },function(data){
		        	if(!checkStatus(data)) return;		        	
		        	layer.closeAll('loading');
			        $("#goodslist .valueid input[type='checkbox']:checked").each(function(){
	        	   		$(this).closest("tr.sort1").find("td.g-status").html("不同意退款");
	        	   	})
	        	   	$("tr.sort0 input[type='checkbox']:checked").prop("checked",false);
	        		$("#goodslist .valueid input[type='checkbox']:checked").prop("checked",false);
		        	layer.msg(data.info,{icon:1,time:1000}); 
		        },'json')
        	}
        	
        })

	}
})




</script>

</body>
</html>